﻿using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Microsoft.Samples.Web.MobileCapableViewEngine;

namespace Wheels
{
    public class MvcApplication : HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new {controller = "Home", action = "MainMenu", id = ""} // Parameter defaults
                );

            routes.MapRoute(
                "Transit", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new {controller = "Transit", action = "Index", id = ""} // Parameter defaults
                );
        }

        public static void RegisterViewEngines(ViewEngineCollection engines)
        {
            var newMobileCapableWebFormViewEngine = new MobileCapableWebFormViewEngine();
            newMobileCapableWebFormViewEngine.DeviceFolders.Clear();
            newMobileCapableWebFormViewEngine.DeviceFolders.Add("Pocket IE", "WindowsMobile");
            newMobileCapableWebFormViewEngine.DeviceFolders.Add("AppleMAC-Safari", "iPhone");
            newMobileCapableWebFormViewEngine.DeviceFolders.Add("Safari", "iPhone");

            engines.Clear();
            engines.Add(newMobileCapableWebFormViewEngine);
        }

        protected void Application_Start()
        {
            //Microsoft.WindowsAzure.Diagnostics.CrashDumps.EnableCollection(true);

            //DiagnosticMonitorConfiguration diagConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();

            //diagConfig.Logs.ScheduledTransferLogLevelFilter = LogLevel.Information;
            //diagConfig.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);

            //diagConfig.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Error;
            //diagConfig.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);

            //diagConfig.WindowsEventLog.DataSources.Add("System!*");
            //diagConfig.WindowsEventLog.DataSources.Add("Application!*");
            //diagConfig.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);

            //DiagnosticMonitor.Start("DiagnosticsConnectionString", diagConfig);

            RegisterRoutes(RouteTable.Routes);
            RegisterViewEngines(ViewEngines.Engines);
        }
    }
}